      1  import java.util.ArrayList;

      2

      3  public class MockGradeBook implements IGradeBook

      4  {

      5     private ArrayList<Double> scores;

      6

      7     public MockGradeBook() { scores = new ArrayList<Double>(); }

      8

      9     public void addScore(int studentId, double score)

     10     {

     11        // Ignore studentId

     12        scores.add(score);

     13     }

     14

     15     public double getAverageScore(int studentId)

     16     {

     17        double total = 0;

     18        for (double x : scores) { total = total + x; }

     19        return total / scores.size();

     20     }

     21

     22     public void save(String filename)

     23     {

     24        // Do nothing

     25     }

     26

     27     public void load(String filename)

     28     {

     29        // Add sample scores

     30        scores.add(1.0);

     31        scores.add(7.0);

     32        scores.add(2.0);

     33        scores.add(9.0);

     34     }

     35  }